package c.e.a.b.f.b;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import c.e.a.b.b.j.c;
import c.e.a.b.e.c.c9;
import java.util.Objects;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class f9 {
    public final /* synthetic */ w8 a;

    public f9(w8 w8Var) {
        this.a = w8Var;
    }

    public final void a() {
        this.a.g();
        d4 l = this.a.l();
        Objects.requireNonNull((c) this.a.a.n);
        if (l.u(System.currentTimeMillis())) {
            this.a.l().r.a(true);
            RunningAppProcessInfo runningAppProcessInfo = new RunningAppProcessInfo();
            ActivityManager.getMyMemoryState(runningAppProcessInfo);
            if (runningAppProcessInfo.importance == 100) {
                this.a.d().n.a("Detected application was in foreground");
                Objects.requireNonNull((c) this.a.a.n);
                c(System.currentTimeMillis(), false);
            }
        }
    }

    public final void b(long j, boolean z) {
        this.a.g();
        this.a.x();
        if (this.a.l().u(j)) {
            this.a.l().r.a(true);
        }
        this.a.l().u.b(j);
        if (this.a.l().r.b()) {
            c(j, z);
        }
    }

    public final void c(long j, boolean z) {
        this.a.g();
        if (this.a.a.i()) {
            this.a.l().u.b(j);
            Objects.requireNonNull((c) this.a.a.n);
            String str = "Session started, time";
            this.a.d().n.b(str, Long.valueOf(SystemClock.elapsedRealtime()));
            Long valueOf = Long.valueOf(j / 1000);
            this.a.n().K("auto", "_sid", valueOf, j);
            this.a.l().r.a(false);
            Bundle bundle = new Bundle();
            bundle.putLong("_sid", valueOf.longValue());
            if (this.a.a.g.o(p.k0) && z) {
                bundle.putLong("_aib", 1);
            }
            this.a.n().E("auto", "_s", j, bundle);
            if (c9.a() && this.a.a.g.o(p.p0)) {
                String a = this.a.l().z.a();
                if (!TextUtils.isEmpty(a)) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putString("_ffr", a);
                    this.a.n().E("auto", "_ssr", j, bundle2);
                }
            }
        }
    }
}
